#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>
#include<stdlib.h>
int main()
{
  pid_t id =fork();
  if(id==0){
  
  char *myargv[] ={"ls","-a","-i","-l",NULL};
  char *myenv[] = {"MYENV=you can see me env",NULL};
  printf("I am a process!\n");  
  sleep(3);
// execl("/usr/bin/ls","ls","-a","-i","-l",NULL);//进程程序替换
// execlp("ls","ls","-a","-l",NULL);
// execv("/usr/bin/ls",myargv);
//  execvp("ls",myargv);
 //execl("./cmd","cmd",NULL);             //可以调用自己写的程序
  execle("./cmd","cmd",NULL,myenv);
//  execl("./test.py","test.py") ; //可以调用python程序
  exit(10);
  }

  
  int status=0;
  pid_t ret=waitpid(id,&status,0);
  if(ret>0)
  {
    printf("signal: %d\n",status&0x7f);
    printf("exit code: %d\n",(status>>8)&0xff);
  }
  return 0;
}
